Skip to content

[Release-2.0]Fix 9829 : do not report error using import, export, module augmentation in d.t.s #9870

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

Closed
wants to merge 116 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
cccf70b
Add failing test
RyanCavanaugh Jun 23, 2016
c35e374
runtests-parallel skips empty buckets
sandersn Jun 29, 2016
4a77c97
Create tokens using different constructor
sheetalkamat Jun 17, 2016
a2ff4ea
Identifier constructor
sheetalkamat Jun 9, 2016
29985f3
Update language in comment
mhegazy Jul 5, 2016
4c6b984
Add .mailmap file
mhegazy Jul 6, 2016
6fe105e
Add authors script to generate authors from repo
mhegazy Jul 6, 2016
8b20ad0
Update AUTHORS.md for release-2.0
mhegazy Jul 6, 2016
9ff0cab
Update script to pass more than one argument
mhegazy Jul 6, 2016
94f2169
Merge pull request #9534 from Microsoft/updateAuthors
mhegazy Jul 6, 2016
635826f
Remove the unused text buffer from ScriptInfo
sheetalkamat Jul 6, 2016
08a0137
Set default flags on all nodes
sheetalkamat Jul 6, 2016
9a39f9c
Merge branch 'release-2.0'
mhegazy Jul 6, 2016
a039412
Update LKG
mhegazy Jul 6, 2016
3e42733
Merge pull request #9428 from Microsoft/runtests-parallel-skips-empty…
sandersn Jul 7, 2016
4b5f7e5
Swap q from a reference to an import
weswigham Jul 7, 2016
1ee3f99
Fix #9550: exclude 'this' type parameters from unusedParameters checks.
tetsuharuohzeki Jul 7, 2016
e1c69d7
Merge pull request #9537 from Microsoft/removeContentFromScriptInfo
sheetalkamat Jul 7, 2016
f9102d0
Update comment to reflect new dependency
weswigham Jul 7, 2016
7c1df15
Merge pull request #9556 from weswigham/import-q
weswigham Jul 7, 2016
99748a2
Merge pull request #9557 from saneyuki/fix-unusedparam-this
mhegazy Jul 7, 2016
4de0a05
Make TemplateStringsArray completely immutable.
DanielRosenwasser Jul 7, 2016
fd66760
Avoid putting children tags in jsdoccomment
zhengbli Jul 7, 2016
5c498cd
Parse the result of getDirectories call
mhegazy Jul 7, 2016
f0d5ff6
Update harness getDirectories implementation for shims
mhegazy Jul 7, 2016
4721b91
Fix multiple Salsa assignment-declarations
sandersn Jul 8, 2016
f84b731
Test for multiple salsa assignment-declarations
sandersn Jul 8, 2016
ebc75a2
Add test for parsed @typedef tag node shape
zhengbli Jul 7, 2016
81e8840
Merge pull request #9565 from zhengbli/fixTypedefParsingIssue
zhengbli Jul 8, 2016
3c1a69b
Provide a symbol for salsa-inferred class types
sandersn Jul 8, 2016
b543074
Compile with --noImplicitThis
sandersn Jul 8, 2016
348a4e9
Fixed up tests that used 'string[]' instead of 'TemplateStringsArray'.
DanielRosenwasser Jul 9, 2016
0961352
Accepted baselines.
DanielRosenwasser Jul 9, 2016
37eac5f
Update .mailmap
mhegazy Jul 10, 2016
ca874bd
Fix module tracking
billti Jul 10, 2016
db54bda
Updated test with relative import
billti Jul 10, 2016
2ab1143
Fixed the node tracking and a harness bug
billti Jul 11, 2016
a7467a1
fixed lint error
billti Jul 11, 2016
b75053c
Fixed implicit any
billti Jul 11, 2016
97025d0
Added missing test files
billti Jul 11, 2016
21bf801
Removed duplicate logic
billti Jul 11, 2016
cf15e82
Fix `this` in harness and improve gulpfile defaults
sandersn Jul 11, 2016
6d21cf6
Add more default options to gulpfile
sandersn Jul 11, 2016
a3d9a85
Add --pretty to tsconfigs
sandersn Jul 11, 2016
0764590
Make sure the order of setting pos, end, flags, parent, kind is consi…
sheetalkamat Jul 11, 2016
767da71
Add __tokentag to Token
sheetalkamat Jul 11, 2016
135cc12
Merge pull request #9574 from Microsoft/fix-union-of-salsa-property-t…
sandersn Jul 11, 2016
a138e63
Avoid using `this` in object literals where possible
sandersn Jul 11, 2016
cc83c79
Merge pull request #9578 from Microsoft/fix-salsa-out-of-memory-on-me…
sandersn Jul 11, 2016
73f7414
fix the issue that @property types are not recoganized
zhengbli Jul 11, 2016
6ad4482
Update conflicting baseline.
sandersn Jul 11, 2016
2f768f6
Merge pull request #9607 from Microsoft/issue9542
billti Jul 11, 2016
6414a57
Remove another use of `this`, in program.ts
sandersn Jul 11, 2016
78a1ca7
Make setting properties explicit instead of using parameter properties
sheetalkamat Jul 11, 2016
1d202f6
Merge pull request #9622 from Microsoft/update-conflicting-baseline
sandersn Jul 11, 2016
c19512e
Add node flag check
zhengbli Jul 11, 2016
f19844f
Merge pull request #9580 from Microsoft/compile-with-noImplicitThis
sandersn Jul 11, 2016
fb20df0
Have tsconfig for harness
weswigham Jul 11, 2016
cfe3aad
Move unittests into harness
weswigham Jul 12, 2016
5960877
Merge pull request #9628 from Microsoft/tsconfig-for-harness
weswigham Jul 12, 2016
48ab0ce
Change version to 2.1.0 (#9615)
yuit Jul 12, 2016
5d37c29
Handle JSX bodies in formatter
Jul 8, 2016
f9d2937
Merge pull request #9647 from Microsoft/format_tsx
Jul 12, 2016
c90897c
Treat "." and ".." as relative module names
Jul 12, 2016
e6e6a8b
Use regex
Jul 13, 2016
8e679b7
Remove duplicate startsWith and endsWith functions
Jul 13, 2016
34e81f2
Add formatDiagnostics utility
alexeagle Jul 13, 2016
919e31a
Include resolution trace
Jul 13, 2016
049610e
Merge pull request #9689 from alexeagle/formatDiags
mhegazy Jul 13, 2016
9eeb69d
Merge pull request #9621 from zhengbli/fixJSDocPropertyTag
zhengbli Jul 13, 2016
5efbf61
Skip `this` in emitter in 2 more places
sandersn Jul 13, 2016
2cc040c
Test that emitter skips `this` with rest parameter
sandersn Jul 13, 2016
df59058
Fix endsWith bug
Jul 13, 2016
1546974
Merge pull request #9676 from Microsoft/relative_module
Jul 13, 2016
5484e75
Remove extra semicolon
weswigham Jul 13, 2016
23f4be9
Merge pull request #9695 from Microsoft/weswigham-patch-1
weswigham Jul 13, 2016
ebb0906
Use originalKeywordKind to detect this parameters
sandersn Jul 13, 2016
62f49c3
use getNewLine from host rather than sys
alexeagle Jul 13, 2016
a706ad5
fix absolute paths in baselines
vladima Jul 13, 2016
3625637
Merge pull request #9710 from Microsoft/fixAbsolutePath
vladima Jul 13, 2016
d7e17aa
Merge pull request #9704 from alexeagle/master
mhegazy Jul 13, 2016
4f9a234
move endsWith to core.ts
vladima Jul 14, 2016
cc4b331
Merge pull request #9716 from Microsoft/moveEndsWIth
vladima Jul 14, 2016
695582e
Tell travis to build on OSX in addition to Linux (#9717)
weswigham Jul 14, 2016
3cb0513
Have travis fast_finish (#9718)
weswigham Jul 14, 2016
b8e814e
Harden compilerRunner vs rooted path names in tests (#9714)
weswigham Jul 14, 2016
f16f276
Merge pull request #9529 from Microsoft/identifierAndTokenConstructor
sheetalkamat Jul 14, 2016
2da6846
use sys based host for formatting diagnostics
vladima Jul 15, 2016
d66837b
Fixes capitalization (#9736)
tinganho Jul 15, 2016
4954f81
Fix a command example in help messages (#9747)
falsandtru Jul 15, 2016
859bd1b
Merge pull request #9750 from Microsoft/fixFormatDiagnostics
vladima Jul 15, 2016
761482c
Use sorcery to merge sourcemaps between browserify and gulp-typescrip…
weswigham Jul 15, 2016
87f75ff
Use reference types to reference node.d.ts (#9686)
yuit Jul 16, 2016
22cac1a
Provide the complete path to tsconfig file. Fixes #9785
RyanCavanaugh Jul 18, 2016
3d3ae29
Merge pull request #9798 from RyanCavanaugh/fix_9785
RyanCavanaugh Jul 18, 2016
59c4d3f
Merge branch 'release-2.0'
mhegazy Jul 18, 2016
ac72aff
Update LKG
mhegazy Jul 18, 2016
32a9196
Merge branch 'mergerRelease-2.0InMaster'
mhegazy Jul 18, 2016
e52e165
Port Fix9685 to master (#9788)
yuit Jul 18, 2016
2a26beb
Add performance framework from transforms branch (#9536)
weswigham Jul 19, 2016
80db0f2
[Release-2.0] Fix 9782: do not report blocked-scope-used-before-decl…
yuit Jul 19, 2016
729464d
Integrate feedback from @mihailik to performance framework (#9845)
weswigham Jul 20, 2016
82de932
Merge branch 'master' into tsaImmutable
DanielRosenwasser Jul 21, 2016
1b07fbb
Fix #9843. IScriptSnapshot can return undefined
HerringtonDarkholme Jul 21, 2016
6e4dd75
Merge pull request #9561 from Microsoft/tsaImmutable
DanielRosenwasser Jul 21, 2016
a2f45e9
Merge pull request #9853 from HerringtonDarkholme/master
DanielRosenwasser Jul 21, 2016
57eac1b
Merge pull request #9692 from Microsoft/fix-emit-with-this-and-rest-p…
sandersn Jul 21, 2016
adff787
Only error in non-declaration file
Jul 21, 2016
7d16935
Add tests and baselines
Jul 21, 2016
f24341f
Remove dependency on tsd, Related to #9658 (#9724)
sudheesh001 Jul 21, 2016
395e6c9
Addess PR: get the first non-ambient external module file
Jul 21, 2016
03eb4ac
Rename test file and update baseline
Jul 21, 2016
33b7149
Add tests and baselines
Jul 21, 2016
d6b2761
Merge branch 'master' into fix9829
Jul 22, 2016
398e65e
Update baselines
Jul 22, 2016
856c89c
Revert "Merge branch 'master' into fix9829"
Jul 22, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2263,7 +2263,7 @@ namespace ts {
const languageVersion = options.target || ScriptTarget.ES3;
const outFile = options.outFile || options.out;

const firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
if (options.isolatedModules) {
if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES6) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
Expand All @@ -2275,20 +2275,20 @@ namespace ts {
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && options.module === ModuleKind.None) {
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && options.module === ModuleKind.None) {
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
const span = getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
programDiagnostics.add(createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
}

// Cannot specify module gen that isn't amd or system with --out
if (outFile) {
if (options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
}
else if (options.module === undefined && firstExternalModuleSourceFile) {
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
const span = getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
programDiagnostics.add(createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=== tests/cases/compiler/0.d.ts ===

export = a;
>a : Symbol(a, Decl(0.d.ts, 2, 11))

declare var a: number;
>a : Symbol(a, Decl(0.d.ts, 2, 11))

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=== tests/cases/compiler/0.d.ts ===

export = a;
>a : number

declare var a: number;
>a : number

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tests/cases/compiler/1.ts(2,1): error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'.


==== tests/cases/compiler/1.ts (1 errors) ====

export var j = "hello"; // error
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'.

==== tests/cases/compiler/0.d.ts (0 errors) ====
export = a;
declare var a: number;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/noErrorUsingImportExportModuleAugmentationInDeclarationFile2.ts] ////

//// [1.ts]

export var j = "hello"; // error

//// [0.d.ts]
export = a;
declare var a: number;

//// [1.js]
"use strict";
exports.j = "hello"; // error
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests/cases/compiler/1.ts(1,1): error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'.


==== tests/cases/compiler/0.d.ts (0 errors) ====

export = a;
declare var a: number;

==== tests/cases/compiler/1.ts (1 errors) ====
export var j = "hello"; // error
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//// [tests/cases/compiler/noErrorUsingImportExportModuleAugmentationInDeclarationFile3.ts] ////

//// [0.d.ts]

export = a;
declare var a: number;

//// [1.ts]
export var j = "hello"; // error


//// [1.js]
"use strict";
exports.j = "hello"; // error
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @module: none
// @filename: 0.d.ts

export = a;
declare var a: number;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @module: none

// @filename: 1.ts
export var j = "hello"; // error

// @filename: 0.d.ts
export = a;
declare var a: number;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @module: none

// @filename: 0.d.ts
export = a;
declare var a: number;

// @filename: 1.ts
export var j = "hello"; // error