@@ -733,7 +733,7 @@ namespace ts {
733
733
decl . modifiers ,
734
734
decl . importClause ,
735
735
rewriteModuleSpecifier ( decl , decl . moduleSpecifier ) ,
736
- getResolutionModeOverrideForClause ( decl . assertClause ) ? decl . assertClause : undefined
736
+ getResolutionModeOverrideForClauseInNightly ( decl . assertClause )
737
737
) ;
738
738
}
739
739
// The `importClause` visibility corresponds to the default's visibility.
@@ -745,7 +745,7 @@ namespace ts {
745
745
decl . importClause . isTypeOnly ,
746
746
visibleDefaultBinding ,
747
747
/*namedBindings*/ undefined ,
748
- ) , rewriteModuleSpecifier ( decl , decl . moduleSpecifier ) , getResolutionModeOverrideForClause ( decl . assertClause ) ? decl . assertClause : undefined ) ;
748
+ ) , rewriteModuleSpecifier ( decl , decl . moduleSpecifier ) , getResolutionModeOverrideForClauseInNightly ( decl . assertClause ) ) ;
749
749
}
750
750
if ( decl . importClause . namedBindings . kind === SyntaxKind . NamespaceImport ) {
751
751
// Namespace import (optionally with visible default)
@@ -755,7 +755,7 @@ namespace ts {
755
755
decl . importClause . isTypeOnly ,
756
756
visibleDefaultBinding ,
757
757
namedBindings ,
758
- ) , rewriteModuleSpecifier ( decl , decl . moduleSpecifier ) , getResolutionModeOverrideForClause ( decl . assertClause ) ? decl . assertClause : undefined ) : undefined ;
758
+ ) , rewriteModuleSpecifier ( decl , decl . moduleSpecifier ) , getResolutionModeOverrideForClauseInNightly ( decl . assertClause ) ) : undefined ;
759
759
}
760
760
// Named imports (optionally with visible default)
761
761
const bindingList = mapDefined ( decl . importClause . namedBindings . elements , b => resolver . isDeclarationVisible ( b ) ? b : undefined ) ;
@@ -771,7 +771,7 @@ namespace ts {
771
771
bindingList && bindingList . length ? factory . updateNamedImports ( decl . importClause . namedBindings , bindingList ) : undefined ,
772
772
) ,
773
773
rewriteModuleSpecifier ( decl , decl . moduleSpecifier ) ,
774
- getResolutionModeOverrideForClause ( decl . assertClause ) ? decl . assertClause : undefined
774
+ getResolutionModeOverrideForClauseInNightly ( decl . assertClause )
775
775
) ;
776
776
}
777
777
// Augmentation of export depends on import
@@ -782,12 +782,23 @@ namespace ts {
782
782
decl . modifiers ,
783
783
/*importClause*/ undefined ,
784
784
rewriteModuleSpecifier ( decl , decl . moduleSpecifier ) ,
785
- getResolutionModeOverrideForClause ( decl . assertClause ) ? decl . assertClause : undefined
785
+ getResolutionModeOverrideForClauseInNightly ( decl . assertClause )
786
786
) ;
787
787
}
788
788
// Nothing visible
789
789
}
790
790
791
+ function getResolutionModeOverrideForClauseInNightly ( assertClause : AssertClause | undefined ) {
792
+ const mode = getResolutionModeOverrideForClause ( assertClause ) ;
793
+ if ( mode !== undefined ) {
794
+ if ( ! isNightly ( ) ) {
795
+ context . addDiagnostic ( createDiagnosticForNode ( assertClause ! , Diagnostics . Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next ) ) ;
796
+ }
797
+ return assertClause ;
798
+ }
799
+ return undefined ;
800
+ }
801
+
791
802
function transformAndReplaceLatePaintedStatements ( statements : NodeArray < Statement > ) : NodeArray < Statement > {
792
803
// This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during
793
804
// error handling which must now be included in the output and themselves checked for errors.
0 commit comments