Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add es3.d.ts #28372

Closed
wants to merge 12 commits into from
  •  
  •  
  •  
1 change: 1 addition & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace ts {
// augmented in another lib.
const libEntries: [string, string][] = [
// JavaScript only
["es3", "lib.es3.d.ts"],
["es5", "lib.es5.d.ts"],
["es6", "lib.es2015.d.ts"],
["es2015", "lib.es2015.d.ts"],
Expand Down
20 changes: 16 additions & 4 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,20 @@ namespace FourSlash {
}
});
if (!compilationOptions.noLib) {
this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName,
Harness.Compiler.getDefaultLibrarySourceFile()!.text, /*isRootFile*/ false);
const libs = compilationOptions.lib || [Harness.Compiler.defaultLibFileName];
const libFiles = libs.map(lib => {
const sourceFile = Harness.Compiler.getDefaultLibrarySourceFile(lib)!;
this.languageServiceAdapterHost.addScript(lib, sourceFile.text, /*isRootFile*/ false);
return sourceFile;
});
for (const libFile of libFiles) {
const resolvedResult = ts.preProcessFile(libFile.text);
for (const libReference of resolvedResult.libReferenceDirectives) {
const mapped = ts.libMap.get(libReference.fileName.toLowerCase())!;
this.languageServiceAdapterHost.addScript(mapped,
Harness.Compiler.getDefaultLibrarySourceFile(mapped)!.text, /*isRootFile*/ false);
}
}
}
}

Expand Down Expand Up @@ -3649,7 +3661,7 @@ namespace FourSlashInterface {
}

export class Plugins {
constructor (private state: FourSlash.TestState) {
constructor(private state: FourSlash.TestState) {
}

public configurePlugin(pluginName: string, configuration: any): void {
Expand Down Expand Up @@ -4719,7 +4731,6 @@ namespace FourSlashInterface {
functionEntry("encodeURIComponent"),
functionEntry("escape"),
functionEntry("unescape"),
varEntry("NaN"),
varEntry("Infinity"),
varEntry("Object"),
varEntry("Function"),
Expand Down Expand Up @@ -4750,6 +4761,7 @@ namespace FourSlashInterface {
varEntry("Float32Array"),
varEntry("Float64Array"),
moduleEntry("Intl"),
varEntry("NaN"),
];

const globalKeywordsInsideFunction: ReadonlyArray<ExpectedCompletionEntryObject> = [
Expand Down
1 change: 1 addition & 0 deletions src/lib/es3.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var NaN: number;
4 changes: 4 additions & 0 deletions src/lib/es3.full.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// <reference lib="es3" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
2 changes: 1 addition & 1 deletion src/lib/es5.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// <reference lib="es3" />
/////////////////////////////
/// ECMAScript APIs
/////////////////////////////

declare var NaN: number;
declare var Infinity: number;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/lib/libs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"libs": [
// JavaScript only
"es3",
"es5",
"es2015",
"es2016",
Expand Down Expand Up @@ -44,6 +45,7 @@
"esnext.bigint",
"esnext.intl",
// Default libraries
"es3.full",
"es5.full",
"es2015.full",
"es2016.full",
Expand Down
6 changes: 3 additions & 3 deletions src/testRunner/unittests/config/commandLineParsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace ts {
assertParseResult(["--lib", "es5,invalidOption", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
messageText: "Argument for '--lib' option must be: 'es3', 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
Expand Down Expand Up @@ -259,7 +259,7 @@ namespace ts {
assertParseResult(["--lib", "es5,", "es7", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
messageText: "Argument for '--lib' option must be: 'es3', 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
Expand All @@ -278,7 +278,7 @@ namespace ts {
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
{
errors: [{
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
messageText: "Argument for '--lib' option must be: 'es3', 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.string', 'es2020.symbol.wellknown', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.",
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
file: undefined,
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/enumConstantMembers.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum E5 {

e = NaN,
>e : Symbol(E5.e, Decl(enumConstantMembers.ts, 24, 18))
>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --))
>NaN : Symbol(NaN, Decl(lib.es3.d.ts, --, --))

f = Infinity,
>f : Symbol(E5.f, Decl(enumConstantMembers.ts, 25, 12))
Expand Down Expand Up @@ -86,7 +86,7 @@ const enum E6 {

e = NaN,
>e : Symbol(E6.e, Decl(enumConstantMembers.ts, 34, 18))
>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --))
>NaN : Symbol(NaN, Decl(lib.es3.d.ts, --, --))

f = Infinity,
>f : Symbol(E6.f, Decl(enumConstantMembers.ts, 35, 12))
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/fixSignatureCaching.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ define(function () {
>version : Symbol(version, Decl(fixSignatureCaching.ts, 431, 11))
>impl : Symbol(impl, Decl(fixSignatureCaching.ts, 6, 7))
>version : Symbol(version, Decl(fixSignatureCaching.ts, 431, 11))
>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --))
>NaN : Symbol(NaN, Decl(lib.es3.d.ts, --, --))

};

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/baselines/reference/moduleScoping.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var v4 = {a: true, b: NaN}; // Should shadow global v2 in this module
>v4 : Symbol(v4, Decl(file4.ts, 4, 3))
>a : Symbol(a, Decl(file4.ts, 4, 10))
>b : Symbol(b, Decl(file4.ts, 4, 18))
>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --))
>NaN : Symbol(NaN, Decl(lib.es3.d.ts, --, --))

=== tests/cases/conformance/externalModules/file5.ts ===
var x = v2; // Should be global v2 of type number again
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/noImplicitAnyIndexing.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var m: MyMap<number> = {

"Okay that's enough for today.": NaN
>"Okay that's enough for today." : Symbol("Okay that's enough for today.", Decl(noImplicitAnyIndexing.ts, 39, 11))
>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --))
>NaN : Symbol(NaN, Decl(lib.es3.d.ts, --, --))

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var m: MyMap<number> = {

"Okay that's enough for today.": NaN
>"Okay that's enough for today." : Symbol("Okay that's enough for today.", Decl(noImplicitAnyIndexingSuppressed.ts, 38, 11))
>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --))
>NaN : Symbol(NaN, Decl(lib.es3.d.ts, --, --))

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"decl.ts",
"emit.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"decl.ts",
"emit.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"decl.ts",
"dont_emit.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"decl.ts",
"dont_emit.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"nestedModule.ts"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"baselineCheck": true,
"runTest": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"nestedModule.ts"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"decl.ts"
],
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"decl.ts"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"decl.ts"
],
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"decl.ts"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"consume.ts"
],
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"decl.ts",
"consume.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"consume.ts"
],
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"decl.ts",
"consume.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
],
"runTest": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"b.ts",
"c.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
],
"runTest": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"b.ts",
"c.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"declarationDir": "declarations",
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"subfolder/b.ts",
"a.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"declarationDir": "declarations",
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"subfolder/b.ts",
"a.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"declarationDir": "declarations",
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"subfolder/b.ts",
"a.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"declarationDir": "declarations",
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"subfolder/b.ts",
"a.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"declarationDir": "declarations",
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"subfolder/b.ts",
"a.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"declarationDir": "declarations",
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"subfolder/b.ts",
"a.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"m4.ts",
"useModule.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"m4.ts",
"useModule.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"useModule.d.ts"
],
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"decl.d.ts",
"useModule.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"useModule.d.ts"
],
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"decl.d.ts",
"useModule.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"glo_m4.ts",
"useModule.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"glo_m4.ts",
"useModule.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"private_m4.ts",
"useModule.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"private_m4.ts",
"useModule.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"fncOnly_m4.ts",
"useModule.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.es3.d.ts",
"lib.es5.d.ts",
"fncOnly_m4.ts",
"useModule.ts"
Expand Down
Loading