---
title: "compileTsSource(): TypeShade 셰이더 API의 작성 분류 함수 참조 문서"
description: "compileTsSource, TypeShade API의 작성 분류에 속하는 함수입니다. TypeScript 소스 문자열을 TypeShade 작성 파이프라인으로 컴파일합니다."
url: https://typeshade.dev/ko/api/compiletssource/
language: ko
---

# `compileTsSource()`

함수, 작성 분류

TypeScript 소스 문자열을 TypeShade 작성 파이프라인으로 컴파일합니다.

`import { compileTsSource } from 'typeshade'`

설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.

## 구문

```ts
function compileTsSource(
  source: string,
  options: CompileTsSourceOptions = {},
): CompileTsSourceResult
```

## 매개변수

**`source` `string`**

**`options` 선택 사항 `CompileTsSourceOptions`**

## 반환값

`CompileTsSourceResult`

## 설명

`"use typeshade"` 지시문이 없는 소스는 `hasDirective: false`를 반환합니다. 이때는 함수가 없고 `MISSING_DIRECTIVE` error가 하나 있습니다. 다만 `options.requireDirective`가 `false`이면 이 오류는 발생하지 않습니다. `wgsl`은 error 진단 없이 하향 변환된 함수가 하나 이상 있고 `options.emit`이 `false`가 아닐 때에만 있습니다. 이런 모듈에서 백엔드가 예외를 던지면 `BACKEND` error 진단으로 보고되며, `wgsl`이 정의되지 않은 채로 남습니다.

## 소스

[`src/compiler/ts/source-file.ts`, 186행](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/source-file.ts#L186), 커밋 af54ddad5 기준
