Skip to content

Commit

Permalink
split typescript projects
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkishi committed Jun 10, 2019
1 parent 616e1eb commit 29b5218
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.svelte linguist-language=HTML
tsconfig*.json linguist-language=javascript
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"posttest": "agadoo internal/index.mjs",
"prepublishOnly": "export PUBLISH=true && npm test && npm run create-stubs",
"create-stubs": "node scripts/create-stubs.js",
"tsd": "tsc -p . --emitDeclarationOnly",
"typecheck": "tsc -p . --noEmit",
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
"typecheck": "tsc -p src/compiler --noEmit && tsc -p src/runtime --noEmit",
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assign } from '../../runtime/internal/index';
import { assign } from '../../runtime/internal/utils';
import Stats from '../Stats';
import parse from '../parse/index';
import render_dom from './render-dom/index';
Expand Down
11 changes: 11 additions & 0 deletions src/compiler/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.base.json",
"include": ["."],

"compilerOptions": {
"lib": ["es2017", "webworker"]

// TODO: remove mocha types from the whole project
// "types": ["node", "estree"]
}
}
3 changes: 2 additions & 1 deletion src/runtime/internal/animations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { identity as linear, noop, now } from './utils';
import { identity as linear, noop } from './utils';
import { now } from "./environment";
import { loop } from './loop';
import { create_rule, delete_rule } from './style_manager';
import { AnimationConfig } from '../animate';
Expand Down
18 changes: 18 additions & 0 deletions src/runtime/internal/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { noop } from './utils';

export const is_client = typeof window !== 'undefined';

export let now: () => number = is_client
? () => window.performance.now()
: () => Date.now();

export let raf = is_client ? requestAnimationFrame : noop;

// used internally for testing
export function set_now(fn) {
now = fn;
}

export function set_raf(fn) {
raf = fn;
}
1 change: 1 addition & 0 deletions src/runtime/internal/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './animations';
export * from './await-block';
export * from './dom';
export * from './environment';
export * from './keyed-each';
export * from './lifecycle';
export * from './loop';
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/internal/loop.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { now, raf } from './utils';
import { now, raf } from "./environment";

export interface Task { abort(): void; promise: Promise<void> }

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/internal/style_manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { element } from './dom';
import { raf } from './utils';
import { raf } from "./environment";

let stylesheet;
let active = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/internal/transitions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { identity as linear, is_function, noop, now, run_all } from './utils';
import { identity as linear, is_function, noop, run_all } from './utils';
import { now } from "./environment";
import { loop } from './loop';
import { create_rule, delete_rule } from './style_manager';
import { custom_event } from './dom';
Expand Down
17 changes: 0 additions & 17 deletions src/runtime/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,3 @@ export function once(fn) {
fn.call(this, ...args);
}
}

const is_client = typeof window !== 'undefined';

export let now: () => number = is_client
? () => window.performance.now()
: () => Date.now();

export let raf = is_client ? requestAnimationFrame : noop;

// used internally for testing
export function set_now(fn) {
now = fn;
}

export function set_raf(fn) {
raf = fn;
}
15 changes: 15 additions & 0 deletions src/runtime/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.base.json",
"include": ["."],

"compilerOptions": {
"lib": ["es2015", "dom", "dom.iterable"],
"target": "es2015",
"types": [],

"baseUrl": ".",
"paths": {
"svelte/*": ["*"]
}
}
}
10 changes: 10 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig.base.json",
"include": ["."],

"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true
}
}
28 changes: 28 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"rootDir": "src",

// target node v8+ (https://node.green/)
// the only missing feature is Array.prototype.values
"lib": ["es2017"],
"target": "es2017",

"declaration": true,
"declarationDir": "types",

"noEmitOnError": true,
"noErrorTruncation": true,

// rollup takes care of these
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,

// TODO: error all the things
//"strict": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true
}
}
33 changes: 0 additions & 33 deletions tsconfig.json

This file was deleted.

0 comments on commit 29b5218

Please sign in to comment.