Closed
Description
We rely on the performance improvement of skipping type-checking of lib.d.ts.
But, as I described in #5504 our setup is to emit ES6 while using the types from lib.d.ts. (es5).
It seems that if I pass the lib.d.ts on the command line, rather than rely on the auto-loading behavior, then the isDefaultLib
argument is always false, here:
https://github.com/Microsoft/TypeScript/blob/v1.6.2/src/compiler/program.ts#L371
So that means it's slow again:
alexeagle-macbookpro2:test123 alexeagle$ time ./node_modules/.bin/tsc -p targetES6
real 0m0.696s
user 0m0.835s
sys 0m0.050s
alexeagle-macbookpro2:test123 alexeagle$ time ./node_modules/.bin/tsc -p targetES6
real 0m0.703s
user 0m0.846s
sys 0m0.049s
alexeagle-macbookpro2:test123 alexeagle$ time ./node_modules/.bin/tsc -p targetES5
real 0m0.375s
user 0m0.443s
sys 0m0.033s
alexeagle-macbookpro2:test123 alexeagle$ time ./node_modules/.bin/tsc -p targetES5
real 0m0.379s
user 0m0.441s
sys 0m0.035s
Could that hardcoded false
be changed to a predicate of whether the file passed is known to be a standard lib (either with the /// <reference no-default-lib="true"/>
pragma or because the path matches compilerHost#getDefaultLibFileName
)?
Here's the repro directory:
alexeagle-macbookpro2:test123 alexeagle$ find target* -type f -print -exec cat {} \;
targetES5/app.ts
let a: string = "hello";
targetES5/built/app.js
var a = "hello";
targetES5/tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"skipDefaultLibCheck": true,
"noImplicitAny": false,
"outDir": "built",
"rootDir": ".",
"sourceMap": false
},
"exclude": [
"node_modules"
]
}
targetES6/app.ts
let a: string = "hello";
targetES6/built/app.js
let a = "hello";
targetES6/lib.es6-emit.d.ts
/**
* @fileoverview a subset of typings from lib.core.es6.d.ts which are required
* for the compiler to emit ES6 code, even though we only allow ES5 API usage.
* This custom typing is a suggested workaround for
* https://github.com/Microsoft/TypeScript/issues/5504
*/
interface IteratorResult<T> {
done: boolean;
value?: T;
}
interface Iterator<T> {
next(value?: any): IteratorResult<T>;
return?(value?: any): IteratorResult<T>;
throw?(e?: any): IteratorResult<T>;
}
interface Iterable<T> {
[Symbol.iterator](): Iterator<T>;
}
interface IterableIterator<T> extends Iterator<T> {
[Symbol.iterator](): IterableIterator<T>;
}
interface Symbol {
/** Returns a string representation of an object. */
toString(): string;
/** Returns the primitive value of the specified object. */
valueOf(): Object;
[Symbol.toStringTag]: string;
}
interface SymbolConstructor {
/**
* A reference to the prototype.
*/
prototype: Symbol;
/**
* Returns a new unique Symbol value.
* @param description Description of the new Symbol object.
*/
(description?: string|number): symbol;
/**
* Returns a Symbol object from the global symbol registry matching the given key if found.
* Otherwise, returns a new symbol with this key.
* @param key key to search for.
*/
for(key: string): symbol;
/**
* Returns a key from the global symbol registry matching the given Symbol if found.
* Otherwise, returns a undefined.
* @param sym Symbol to find the key for.
*/
keyFor(sym: symbol): string;
// Well-known Symbols
/**
* A method that determines if a constructor object recognizes an object as one of the
* constructor’s instances. Called by the semantics of the instanceof operator.
*/
hasInstance: symbol;
/**
* A Boolean value that if true indicates that an object should flatten to its array elements
* by Array.prototype.concat.
*/
isConcatSpreadable: symbol;
/**
* A method that returns the default iterator for an object. Called by the semantics of the
* for-of statement.
*/
iterator: symbol;
/**
* A regular expression method that matches the regular expression against a string. Called
* by the String.prototype.match method.
*/
match: symbol;
/**
* A regular expression method that replaces matched substrings of a string. Called by the
* String.prototype.replace method.
*/
replace: symbol;
/**
* A regular expression method that returns the index within a string that matches the
* regular expression. Called by the String.prototype.search method.
*/
search: symbol;
/**
* A function valued property that is the constructor function that is used to create
* derived objects.
*/
species: symbol;
/**
* A regular expression method that splits a string at the indices that match the regular
* expression. Called by the String.prototype.split method.
*/
split: symbol;
/**
* A method that converts an object to a corresponding primitive value.
* Called by the ToPrimitive abstract operation.
*/
toPrimitive: symbol;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built-in method Object.prototype.toString.
*/
toStringTag: symbol;
/**
* An Object whose own property names are property names that are excluded from the 'with'
* environment bindings of the associated objects.
*/
unscopables: symbol;
}
declare var Symbol: SymbolConstructor;
targetES6/tsconfig.json
{
"compilerOptions": {
"target": "es6",
"skipDefaultLibCheck": true,
"noLib": true,
"noImplicitAny": false,
"outDir": "built",
"rootDir": ".",
"sourceMap": false
},
"files": [
"app.ts",
"lib.es6-emit.d.ts",
"../node_modules/typescript/lib/lib.d.ts"
]
}
cc @mprobst
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
DanielRosenwasser commentedon Nov 3, 2015
That was originally the plan for
--skipDefaultLibCheck
, but I think we wanted to avoid overloading the utility of the flag. Additionally, since--skipDefaultLibCheck
was originally used for running our tests and one of our test files is the TypeScript 1.0lib.d.ts
file, we were running into complications with running it.DanielRosenwasser commentedon Nov 3, 2015
@alexeagle I opened #5511; if you'd like to try to pull down that branch and let us know if you get a speedup, we'd appreciate it.
alexeagle commentedon Nov 3, 2015
Thanks for picking that up Daniel. I'll give it a try when Mohamed is done
changing it :)
For now we'll have to use a workaround since we are trying to depend only
on released version of TS
On Tue, Nov 3, 2015 at 1:03 PM Daniel Rosenwasser notifications@github.com
wrote:
mhegazy commentedon Nov 10, 2015
should be in
typescript@next
later tonight.alexeagle commentedon Nov 10, 2015
Thanks!
On Mon, Nov 9, 2015 at 4:05 PM Mohamed Hegazy notifications@github.com
wrote: