Skip to content

Commit

Permalink
feat: MediaType.is_emittable (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Oct 28, 2024
1 parent 8be41cd commit c473be9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,29 @@ impl MediaType {
}
}

/// If the media type can be emitted to JavaScript.
pub fn is_emittable(&self) -> bool {
match self {
MediaType::TypeScript
| MediaType::Mts
| MediaType::Cts
| MediaType::Jsx
| MediaType::Tsx => true,
MediaType::JavaScript
| MediaType::Mjs
| MediaType::Cjs
| MediaType::Dts
| MediaType::Dmts
| MediaType::Dcts
| MediaType::Css
| MediaType::Json
| MediaType::Wasm
| MediaType::TsBuildInfo
| MediaType::SourceMap
| MediaType::Unknown => false,
}
}

/// Returns true if this media type provides types inherently.
///
/// Examples are TypeScript, TSX, or DTS files. Wasm and JSON files are also
Expand Down

0 comments on commit c473be9

Please sign in to comment.