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

feat: remove conditional unstable type-checking #21825

Merged
merged 8 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
10 changes: 1 addition & 9 deletions cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ impl Inner {
"experimentalDecorators": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["deno.ns", "deno.window"],
"lib": ["deno.ns", "deno.window", "deno.unstable"],
"module": "esnext",
"moduleDetection": "force",
"noEmit": true,
Expand All @@ -1135,14 +1135,6 @@ impl Inner {
// TODO(@kitsonk) remove for Deno 1.15
"useUnknownInCatchVariables": false,
}));
let config = &self.config;
let workspace_settings = config.workspace_settings();
if workspace_settings.unstable {
let unstable_libs = json!({
"lib": ["deno.ns", "deno.window", "deno.unstable"]
});
tsconfig.merge(&unstable_libs);
}
if let Err(err) = self.merge_user_tsconfig(&mut tsconfig) {
self.client.show_message(MessageType::WARNING, err);
}
Expand Down
2 changes: 1 addition & 1 deletion cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async fn run_subcommand(flags: Flags) -> Result<i32, AnyError> {
})
}
DenoSubcommand::Types => spawn_subcommand(async move {
let types = tsc::get_types_declaration_file_text(flags.unstable);
let types = tsc::get_types_declaration_file_text();
display::write_to_stdout_ignore_sigpipe(types.as_bytes())
}),
#[cfg(feature = "upgrade")]
Expand Down
18 changes: 10 additions & 8 deletions cli/tests/integration/lsp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,7 @@ fn lsp_exclude_config() {
}

#[test]
fn lsp_hover_unstable_disabled() {
fn lsp_hover_unstable_always_enabled() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let mut client = context.new_lsp_command().build();
client.initialize_default();
Expand All @@ -1930,16 +1930,17 @@ fn lsp_hover_unstable_disabled() {
assert_eq!(
res,
json!({
"contents": [
"contents":[
{
"language": "typescript",
"value": "type Deno.ForeignLibraryInterface = /*unresolved*/ any",
"language":"typescript",
"value":"interface Deno.ForeignLibraryInterface"
},
"",
"**UNSTABLE**: New API, yet to be vetted.\n\nA foreign library interface descriptor.",
"\n\n*@category* - FFI",
],
"range": {
"start": { "line": 0, "character": 14 },
"end": { "line": 0, "character": 37 }
"range":{
"start":{ "line":0, "character":14 },
"end":{ "line":0, "character":37 }
}
})
);
Expand All @@ -1951,6 +1952,7 @@ fn lsp_hover_unstable_enabled() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let mut client = context.new_lsp_command().build();
client.initialize(|builder| {
// NOTE(bartlomieju): this is effectively not used anymore.
builder.set_unstable(true);
});
client.did_open(json!({
Expand Down
7 changes: 1 addition & 6 deletions cli/tools/doc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

use crate::args::CliOptions;
use crate::args::DocFlags;
use crate::args::DocHtmlFlag;
use crate::args::DocSourceFileFlag;
Expand Down Expand Up @@ -29,17 +28,15 @@ use indexmap::IndexMap;
use std::collections::BTreeMap;
use std::path::PathBuf;
use std::rc::Rc;
use std::sync::Arc;

async fn generate_doc_nodes_for_builtin_types(
doc_flags: DocFlags,
cli_options: &Arc<CliOptions>,
capturing_parser: CapturingModuleParser<'_>,
analyzer: &dyn ModuleAnalyzer,
) -> Result<IndexMap<ModuleSpecifier, Vec<doc::DocNode>>, AnyError> {
let source_file_specifier =
ModuleSpecifier::parse("internal://lib.deno.d.ts").unwrap();
let content = get_types_declaration_file_text(cli_options.unstable());
let content = get_types_declaration_file_text();
let mut loader = deno_graph::source::MemoryLoader::new(
vec![(
source_file_specifier.to_string(),
Expand Down Expand Up @@ -90,7 +87,6 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> {
DocSourceFileFlag::Builtin => {
generate_doc_nodes_for_builtin_types(
doc_flags.clone(),
cli_options,
capturing_parser,
&analyzer,
)
Expand Down Expand Up @@ -157,7 +153,6 @@ pub async fn doc(flags: Flags, doc_flags: DocFlags) -> Result<(), AnyError> {
let deno_ns = if doc_flags.source_files != DocSourceFileFlag::Builtin {
let deno_ns = generate_doc_nodes_for_builtin_types(
doc_flags.clone(),
cli_options,
capturing_parser,
&analyzer,
)
Expand Down
9 changes: 3 additions & 6 deletions cli/tsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ pub static COMPILER_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new(
},
);

pub fn get_types_declaration_file_text(unstable: bool) -> String {
pub fn get_types_declaration_file_text() -> String {
let mut assets = get_asset_texts_from_new_runtime()
.unwrap()
.into_iter()
.map(|a| (a.specifier, a.text))
.collect::<HashMap<_, _>>();

let mut lib_names = vec![
let lib_names = vec![
"deno.ns",
"deno.console",
"deno.url",
Expand All @@ -100,12 +100,9 @@ pub fn get_types_declaration_file_text(unstable: bool) -> String {
"deno.shared_globals",
"deno.cache",
"deno.window",
"deno.unstable",
];

if unstable {
lib_names.push("deno.unstable");
}

lib_names
.into_iter()
.map(|name| {
Expand Down